package model

import (
	"auth/model/entity"
)

type UserAuthorityCreateRequest struct {
	UserId      int64 `json:"user_id"`
	AuthorityId int64 `json:"authority_id"`
}

type UserAuthorityUpdateRequest struct {
	ID int64 `json:"id"`

	UserId int64 `json:"user_id"`
}

type UserAuthorityListRequest struct {
	Index int `json:"index"`
	Size  int `json:"size"`

	UserId int64 `json:"user_id"`
}

type UserAuthorityListResponse struct {
	Total int                  `json:"total"`
	Data  []*UserAuthorityInfo `json:"data"`
}

type UserAuthorityInfo struct {
	UserId int64 `json:"user_id"`

	AuthorityId int64 `json:"authority_id"`
}

type UserAuthorityDeleteRequest struct {
}

func UserAuthoritysEntityToDto(userAuthoritys []*entity.UserAuthority) []*UserAuthorityInfo {
	out := make([]*UserAuthorityInfo, 0, len(userAuthoritys))
	for _, c := range userAuthoritys {
		out = append(out, UserAuthorityEntityToDto(c))
	}
	return out
}

func UserAuthorityEntityToDto(e *entity.UserAuthority) *UserAuthorityInfo {
	return &UserAuthorityInfo{

		UserId: e.UserId,

		AuthorityId: e.AuthorityId,
	}
}
